<!DOCTYPE html>
<html lang="utf-8" xmlns:th="http://www.thymeleaf.org">
<head th:replace="include-common :: common-head(~{::title})">
    <title>page</title>
</head>

<head>
    <link rel="stylesheet" th:href="@{/static/css/pagination.css}">
    <script type="text/javascript" th:src="@{/static/jquery/jquery.pagination.js}"></script>
    <script th:inline="javascript">
        $(function (){
           initPagination();
        });

        function initPagination(){
            // 获取分页数据中的总记录数
            /*<![CDATA[*/

                var totalRecord = /*[[${pageInfo.total}]]*/ null;
                var pageNumRecord = /*[[${pageInfo.pageNum-1}]]*/ null;
                var pageSizeRecord = /*[[${pageInfo.pageSize}]]*/ null;

            /*]]>*/
            // 声明 Pagination 设置属性的 JSON 对象
            var properties = {
                num_edge_entries: 3, // 边缘页数
                num_display_entries: 5, // 主体页数
                callback: pageSelectCallback, // 用户点击“翻页”按钮之后执行翻页操作的回调函数
                current_page: pageNumRecord, // 当前页，pageNum 从 1 开始，必须-1 后才可以赋值
                prev_text: "上一页",
                next_text: "下一页",
                items_per_page: pageSizeRecord// 每页显示 1 项
            };
// 调用分页导航条对应的 jQuery 对象的 pagination()方法生成导航条
            $("#Pagination").pagination(totalRecord, properties);
        }

        // 翻页过程中执行的回调函数
        // 点击“上一页”、“下一页”或“数字页码”都会触发翻页动作，从而导致当前函数被调用
        // pageIndex 是用户在页面上点击的页码数值
        function pageSelectCallback(pageIndex, jQuery) {
// pageIndex 是当前页页码的索引，相对于 pageNum 来说，pageIndex 比 pageNum 小 1
            var pageNum = pageIndex + 1;
// 执行页面跳转也就是实现“翻页”
            /*<![CDATA[*/
                var keyword = /*[[${param.keyword}]]*/ null;
            /*]]>*/
            if (keyword == null){
                keyword = "";
            }
            window.location.href = "/admin/page.html?pageNum="+pageNum+"&keyword="+keyword;
// 取消当前超链接的默认行为
            return false;
        }
    </script>
</head>

<body>

<div th:replace="include-common :: common-nav"></div>

<div class="container-fluid">
    <div class="row">
        <div th:replace="include-common :: common-sidebar"></div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="glyphicon glyphicon-th"></i> 数据列表</h3>
                </div>
                <div class="panel-body">
                    <form th:action="@{/admin/page.html}" method="post"  class="form-inline" role="form" style="float:left;">
                        <div class="form-group has-feedback">
                            <div class="input-group">
                                <div class="input-group-addon">查询条件</div>
                                <input name="keyword" class="form-control has-success" type="text" placeholder="请输入查询条件">
                            </div>
                        </div>
                        <button type="submit" class="btn btn-warning"><i class="glyphicon glyphicon-search"></i> 查询
                        </button>
                    </form>
                    <button type="button" class="btn btn-danger" style="float:right;margin-left:10px;"><i
                            class=" glyphicon glyphicon-remove"></i> 删除
                    </button>
                    <a th:href="@{/admin/to/add/page.html}" type="button" class="btn btn-primary" style="float:right;"><i class="glyphicon glyphicon-plus"></i> 新增
                    </a>
                    <br>
                    <hr style="clear:both;">
                    <div class="table-responsive">
                        <table class="table  table-bordered">
                            <thead>
                            <tr>
                                <th width="30">#</th>
                                <th width="30"><input type="checkbox"></th>
                                <th>账号</th>
                                <th>名称</th>
                                <th>邮箱地址</th>
                                <th width="100">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:if="${#lists.isEmpty(pageInfo.list)}">
                                <td colspan="2">抱歉没有查询到数据</td>
                            </tr>
                            <tr th:each="admin:${pageInfo.list}" th:if="${not #lists.isEmpty(pageInfo.list)}">
                                <td th:text="${adminStat.count}"></td>
                                <td><input type="checkbox"></td>
                                <td th:text="${admin.loginAcct}"></td>
                                <td th:text="${admin.userName}"></td>
                                <td th:text="${admin.email}"></td>
                                <td>
                                    <a th:href="@{/assign/to/assign/role/page.html(adminId=${admin.id},pageNum=${pageInfo.pageNum},keyword=${param.keyword})}"
                                            class="btn btn-success btn-xs"><i
                                            class=" glyphicon glyphicon-check"></i></a>
                                    <a th:href="@{/admin/to/edit/page.html(adminId=${admin.id},pageNum=${pageInfo.pageNum},keyword=${param.keyword})}" class="btn btn-primary btn-xs"><i
                                            class=" glyphicon glyphicon-pencil"></i></a>
                                    <a th:href="@{/admin/remove.html(adminId=${admin.id},pageNum=${pageInfo.pageNum},keyword=${param.keyword})}" class="btn btn-danger btn-xs"><i class="glyphicon glyphicon-remove"></i></a>
                                </td>
                            </tr>

                            </tbody>
                            <tfoot>
                                <tr>
                                    <td colspan="6" align="center">
                                        <div id="Pagination" class="pagination">
<!--                                            <span class="current prev">Prev</span>-->
<!--                                            <span class="current">1</span>-->
<!--                                            <a href="#">2</a>-->
<!--                                            <a href="#">3</a>-->
<!--                                            <a href="#">4</a>-->
<!--                                            <span>...</span>-->
<!--                                            <a href="#">8</a>-->
<!--                                            <a href="#" class="next">Next</a>-->
                                        </div>
                                    </td>
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


</body>
</html>